' ***^^^***|||***^^^***
' 
'  This file is regenerated until it's edited. Delete the file to force regeneration.

'  NOTE: This denotes the way the file was created and it's possible the 
'        generation type has since changed.
'        Check the generation script for the curent state of the file.

' %%%###%%%87c9bca68eedf90c5639bd5e6d6ac363%%%###%%%
' %%%##NoWS##%%%76a229449fbd32e69afc14f3410ed3df%%%##NoWS##%%%
' ***^^^***|||***^^^***

  
'************************************************************************************
' Copyright © 2003-2006 Kathleen Dollard
'
' This software is provided 'as-is', without any express or implied warranty. In no 
' event will the author be held liable for any damages arising from the use of this
' software.
' 
' You may use this software for any purpose, including commercial applications, 
' and you may redistribute this software as part of application delivery: however, 
' this copyright notice may not be removed and you may not otherwise redistribute 
' this software directly other than providing a link to wwww.gendotnet.com. 
'
' You may alter this software to better server your needs (I'd like to hear about your 
' changes in order to make the software better). If you alter the softwre, you must  
' clearly mark it as altered and must not be misrepresented as the original software.
' nor wholly your original work.
'*************************************************************************************

Option Explicit On
Option Strict On

Imports System
Imports System.Collections.Generic



Public Class DbsTableColumn
   Implements IViewOrTableColumn

#Region "IViewOrTableColumn Implementation"
   Private Property Name1() As String Implements IViewOrTableColumn.Name
      Get
         Return MyBase.Name
      End Get
      Set(ByVal value As String)
         MyBase.Name = value
      End Set
   End Property

   Private Property AllowNulls1() As Nullable(Of Boolean) Implements IViewOrTableColumn.AllowNulls
      Get
         Return MyBase.AllowNulls
      End Get
      Set(ByVal value As Nullable(Of Boolean))
         MyBase.AllowNulls = value
      End Set
   End Property

   Private Property Caption1() As String Implements IViewOrTableColumn.Caption
      Get
         Return MyBase.Caption
      End Get
      Set(ByVal value As String)
         MyBase.Caption = value
      End Set
   End Property

   Private Property IsAutoIncrement1() As Nullable(Of Boolean) Implements IViewOrTableColumn.IsAutoIncrement
      Get
         Return MyBase.IsAutoIncrement
      End Get
      Set(ByVal value As Nullable(Of Boolean))
         MyBase.IsAutoIncrement = value
      End Set
   End Property

   Private Property IsPrimaryKey1() As Nullable(Of Boolean) Implements IViewOrTableColumn.IsPrimaryKey
      Get
         Return MyBase.IsPrimaryKey
      End Get
      Set(ByVal value As Nullable(Of Boolean))
         MyBase.IsPrimaryKey = value
      End Set
   End Property

   Private Property MaxLength1() As Nullable(Of Integer) Implements IViewOrTableColumn.MaxLength
      Get
         Return MyBase.MaxLength
      End Get
      Set(ByVal value As Nullable(Of Integer))
         MyBase.MaxLength = value
      End Set
   End Property

   Private Property NETType1() As String Implements IViewOrTableColumn.NETType
      Get
         Return MyBase.NETType
      End Get
      Set(ByVal value As String)
         MyBase.NETType = value
      End Set
   End Property

   Private Property OriginalName1() As String Implements IViewOrTableColumn.OriginalName
      Get
         Return MyBase.OriginalName
      End Get
      Set(ByVal value As String)
         MyBase.OriginalName = value
      End Set
   End Property

   Private Property SqlType1() As String Implements IViewOrTableColumn.SqlType
      Get
         Return MyBase.SQLType
      End Get
      Set(ByVal value As String)
         MyBase.SQLType = value
      End Set
   End Property

   Private ReadOnly Property Attributes1() As Attributes Implements IViewOrTableColumn.Attributes
      Get
         Return MyBase.Attributes
      End Get
   End Property
#End Region

End Class

Public Class DbsTableColumnCollection
   Implements IViewOrTableColumnCollection


   Public Function GetTableColumn(ByVal name As String) As DbsTableColumn
      For Each testColumn As DbsTableColumn In Me
         If testColumn.Name = name Then
            Return testColumn
         End If
      Next
      Return Nothing
   End Function

   Default Public Overloads ReadOnly Property Item( _
            ByVal name As String) _
            As DbsTableColumn
      Get
         For Each column As DbsTableColumn In Me
            If column.Name = name Then
               Return column
            End If
         Next
         For Each column As DbsTableColumn In Me
            If column.OriginalName = name Then
               Return column
            End If
         Next
         Return Nothing
      End Get
   End Property

   Public ReadOnly Property HasColumnWithTrueAttribute(ByVal attributeName As String) As Boolean
      Get
         For Each column As DbsTableColumn In Me
            If column.Attributes IsNot Nothing Then
               For Each attribute As Attribute In column.Attributes
                  If attribute.Name.Equals(attributeName, StringComparison.InvariantCultureIgnoreCase) Then
                     If attribute.Value.Equals("true", StringComparison.InvariantCultureIgnoreCase) Then
                        Return True
                     End If
                  End If
               Next
            End If
         Next
         Return False
      End Get
   End Property

   Public ReadOnly Property PrimaryKeys() As DbsTableColumnCollection
      Get
         Dim ret As New DbsTableColumnCollection
         For Each column As DbsTableColumn In Me
            If column.IsPrimaryKey.GetValueOrDefault Then
               ret.Add(column)
            End If
         Next
         Return ret
      End Get
   End Property


#Region "IViewOrTableColumnCollection implementation"
   Public Overloads ReadOnly Property Item1( _
            ByVal columnName As String) _
            As IViewOrTableColumn _
            Implements IViewOrTableColumnCollection.Item

      Get
         Return Item(columnName)
      End Get
   End Property

#End Region
End Class

	